<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let obj = {
        name: "pp",
        age: 12,
      };
      localStorage.setItem("name", "capture");
      localStorage.setItem("info", JSON.stringify(obj));

      function forEachKey(callback) {
        for (let i = 0; i < localStorage.length; i++) {
          callback(localStorage.key(i));
        }
      }

      console.log(localStorage.key(0)); //==>info 获取对应索引值的key
      console.log(localStorage); //==>info 获取对应索引值的key
    </script>
  </body>
</html>
